#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int t; cin >> t;
	while (t--)
	{
		int n; cin >> n;
		vector<int> v(n); for (auto& e : v) cin >> e;
		for (int len = n; len > 0; --len)
		{
			int tgt = -1;
			for(int i = 0; i < n; ++i)
				if (v[i] == 1)
				{ tgt = i; break; }

			int cur_len = 0;
			for (int j = tgt; j >= 0; --j)
			{
				if (v[j] == 0) break;
				v[j]--;
				cur_len++;
			}
			for (int j = tgt + 1; j < n; ++j)
			{
				if (v[j] == 0) break;
				v[j]--;
				cur_len++;
			}
			if (cur_len != len) {
				cout << "NO\n";
				break;
			}
			if (cur_len == 1)
			{
				cout << "YES\n";
				break;
			}
		}
	}
	return 0;
}